package com.itstu.service.impl;

import com.itstu.mapper.FriendMapper;
import com.itstu.pojo.Friend;
import com.itstu.pojo.User;
import com.itstu.service.FriendService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author 梁卓
 * @Version 1.0
 * @ClassName FriendServiceImpl
 * @Description TODO
 * @Date 2024/10/08 20:38
 */
@Service
public class FriendServiceImpl implements FriendService {

    @Resource
    private FriendMapper friendMapper;

    /**
     * 查询好友列表
     * @param uid 登录用户的uid
     * @return 好友列表
     */
    @Override
    public List<User> getFriendList(Long uid) {
        return friendMapper.getFriendList(uid);
    }

    /**
     * 判断是否为好友
     * @param friend 好友信息
     * @return true为好友，false为不是好友
     */
    @Override
    public boolean hasFriend(Friend friend) {
        return friendMapper.hasFriend(friend) > 0 ? true : false;
    }
}
